package demo13_1;

import java.util.Scanner;

public class Login {
    private String username;
    private String password = "123456";


    public  void loginInfo(String password) throws PasswordException{
        if (!this.password.equals(password)) {
            throw new PasswordException("密码错误！");
        }
        System.out.println("登录成功！");
    }

    public static void main(String[] args) {
        System.out.println("请输入密码：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        try {
            Login login = new Login();
            login.loginInfo(name);
        }catch (PasswordException e) {
            e.printStackTrace();
        }
    }
}
